package com.zc.demogetuser;

import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class NearFriendAdapter extends BaseAdapter{

	private List<String> datas;
	private Context context;
	private LayoutInflater inflater;
	
	public NearFriendAdapter(Context ctx, List<String> data){
		context = ctx;
		datas = data;
		inflater = LayoutInflater.from(context);
	}
	
	@Override
	public int getCount() {
		return datas.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		if(convertView == null){
			convertView = inflater.inflate(R.layout.expandable_child, null);
			viewHolder = new ViewHolder();
			viewHolder.icon = (ImageView) convertView.findViewById(R.id.child_icon);
			viewHolder.name = (TextView) convertView.findViewById(R.id.child_name);
			convertView.setTag(viewHolder);
		}else{
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.icon.setImageResource(R.drawable.loading_4);
		viewHolder.name.setText(datas.get(position));

		return convertView;
	}
	
	class ViewHolder{
		private ImageView icon;
		private TextView name;
	}
}
